package com.sqlcheck.exception;

/**
 * 批量操作失败异常
 * 用于明确标识批量操作失败的情况，强调不进行降级处理的设计原则
 */
public class BatchOperationFailedException extends RuntimeException {
    
    private final int expectedCount;
    private final int actualCount;
    private final String operationType;
    
    public BatchOperationFailedException(String operationType, int expectedCount, int actualCount) {
        super(String.format("批量%s操作失败：期望处理%d条记录，实际处理%d条记录", operationType, expectedCount, actualCount));
        this.operationType = operationType;
        this.expectedCount = expectedCount;
        this.actualCount = actualCount;
    }
    
    public BatchOperationFailedException(String operationType, int expectedCount, int actualCount, Throwable cause) {
        super(String.format("批量%s操作失败：期望处理%d条记录，实际处理%d条记录", operationType, expectedCount, actualCount), cause);
        this.operationType = operationType;
        this.expectedCount = expectedCount;
        this.actualCount = actualCount;
    }
    
    public BatchOperationFailedException(String operationType, String message) {
        super(String.format("批量%s操作失败：%s", operationType, message));
        this.operationType = operationType;
        this.expectedCount = -1;
        this.actualCount = -1;
    }
    
    public BatchOperationFailedException(String operationType, String message, Throwable cause) {
        super(String.format("批量%s操作失败：%s", operationType, message), cause);
        this.operationType = operationType;
        this.expectedCount = -1;
        this.actualCount = -1;
    }
    
    public int getExpectedCount() {
        return expectedCount;
    }
    
    public int getActualCount() {
        return actualCount;
    }
    
    public String getOperationType() {
        return operationType;
    }
}